
// 路由配置

// import { createRouter } from "vue-router";
import { createRouter, createWebHashHistory } from "vue-router";
// 所有的页面组件
import Login from "../views/Login.vue"
import Guide from "../views/Guide.vue"
import Reg from "../views/Reg.vue"
import NotFound from "../views/NotFound.vue"
import BadServices from "../views/BadServices.vue"
// import { createWebHashHistory } from "vue-router";

// 定义路由
const routes = [
    {
        path: "/",
        redirect:"/guide"   // redirect 重定向
    },
    {
        path: "/login",
        component: Login
    },
    {
        path: '/reg',
        component: Reg
    },
    {
        path: '/guide',
        component: Guide
    },
    {
        path: '/findpass',
        component: ()=>import('../views/Findpass.vue')
    },
    {
        path: '/demo',
        component: ()=>import('../views/Demo.vue')
    },
    {
        path: '/index',
        component: ()=>import('../views/Index.vue'),
        redirect: '/index/home',
        children:[  // 子路由 + 路由出口 router-view
            {
                path:'/index/home',
                name:'home',
                component:()=>import('../views/Home.vue'),
            },
            {
                path:'/index/classify',
                name:'classify',
                component:()=>import('../views/Classify.vue'),
            },
            {
                path:'/index/cart',
                name:'cart',
                component:()=>import('../views/Cart.vue'),
            },
            {
                path:'/index/mine',
                name:'mine',
                component:()=>import('../views/Mine.vue'),
            },
        ]
    },
    {
        path:'/search',
        name:'search',
        component:()=>import('../views/Search.vue'),
    },
    {
        path: '/404',
        component: NotFound
    },
    {
        path: '/503',
        component: BadServices
    },
    {
        path: '/:pathMatch(.*)',
        component: "/404"
    }
]

// 创建路由
const router = createRouter({
    history: createWebHashHistory(), // 默认路由模式
    routes:routes,
})

// 导出路由
export default router;